<template>
  <view class="exchange-store">
    <customHeader
      class="exchange-store-title"
      title="兑换商城"
      :scrollTop="scrollTop"
    ></customHeader>
    <exchangeHeader :info="info" />
    <goodsContent :goodsInfo="goodsInfo" />
    <!-- 发放奖励弹窗 -->
    <AwardGive :show.sync="showAward" position="exchange_mall" />
  </view>
</template>

<script>
import Taro from "@tarojs/taro";
import customHeader from "@/components/custom-header";
import exchangeHeader from "./components/exchange-header";
import goodsContent from "./components/goods-content";
import AwardGive from "@/components/award-give/index.vue";
import { getFlowerNum, shoppingMallList } from "@/libs/api/exchange-store";
import "./index.scss";
export default {
  components: { customHeader, exchangeHeader, goodsContent, AwardGive },
  data() {
    return {
      scrollTop: 0,
      info: {},
      goodsInfo: [],
      showAward: false
    };
  },
  onShow() {
    this.showAward = true;
    this.handleGetGoodsList();
    this.handleGetInfo();
    Taro.eventCenter.once("get-error", message => {
      this.$message(message);
    });
  },
  onPageScroll({ scrollTop }) {
    this.scrollTop = scrollTop;
  },
  methods: {
    async handleGetInfo() {
      const { data } = await getFlowerNum();
      this.info = data;
    },
    async handleGetGoodsList() {
      const { data } = await shoppingMallList();
      this.goodsInfo = data;
    }
  }
};
</script>
